#ifndef _HASHTABLE_H
#define _HASHTABLE_H
#include "utils.h"
/* Definitions for abstract hashtable. */
typedef struct hashtable_data_t *hashtable_t;

typedef void *hashtable_key_t;
typedef void *hashtable_value_t;

/*
 * hash_function decoration base on a key
 */
typedef int (hashtable_pfhashfunction_t)(hashtable_key_t);

/*
 * value_comparator decoration
 */
typedef boolean_t (hashtable_pfvaluecomparator_t)(hashtable_value_t, hashtable_value_t);

/*
* Creates and returns a new hashtable.
* Return null on failure, else a valid queue.
*/
extern hashtable_t hashtable_create(int min_size, hashtable_pfhashfunction_t hash_fn);
						 

/*
* Set hash_funtion of the hashtable
*/
extern void hashtable_set_hash_function(hashtable_t h, hashtable_pfhashfunction_t pf);

/*
* Set key_comparator of the hashtable
*/
/*
extern void hashtable_set_value_comparator(hashtable_t h, hashtable_pfvaluecomparator_t pf);
*/

/*
 * Add a key value pair(k,v) to a hashtable
 */
extern void hashtable_add(hashtable_t h, hashtable_key_t k, hashtable_value_t v);

/*
 * Lookup the associated value using key
 * Returns the associated value if the is present
 * Returns NULL if the key is not found
 */
extern hashtable_value_t hashtable_lookup(hashtable_t h, hashtable_key_t k);

/*
 * Returns TRUE if the key is present. FALSE otherwise. 
 */
extern boolean_t hashtable_is_present(hashtable_t h, hashtable_key_t k);

/*
 * Delete the associated [key, value] pair from the hash table 
 */
extern void hashtable_remove(hashtable_t h, hashtable_key_t k);

extern void hashtable_debug(hashtable_t h);
#endif //_HASHTABLE_H
